package com.xbs.utils;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.xbs.controller.base.BaseServlet;
import com.xbs.entity.CarEntity;
import com.xbs.service.selfdriving.selfDrivingServiceAdmin;
/**
 * 根据用户传入的订单，获取数据库中有的车牌号
 * @author 余凯
 *
 */
@WebServlet("/ajaxselfcarid")
public class AjaxSelfDrivingGetCarIdServlet extends BaseServlet {
	private selfDrivingServiceAdmin sds;
	private List<CarEntity> car;
	public AjaxSelfDrivingGetCarIdServlet() {
		sds = new selfDrivingServiceAdmin();
		car = new ArrayList<CarEntity>();
	}
	
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		//接受订单编号
		String order = req.getParameter("order");
		//获得车
		car = sds.selCarId(order);
		String str="<option value='请选择'>请选择</option>";
		for(CarEntity c:car){
			str+="<option value='"+c.getCarid()+"'>"+c.getCarid()+"</option>";
		}
		resp.getWriter().print(str);
	}
}
